<?php 
	session_start();
	require("connect.php");
?>
<html><!-- InstanceBegin template="/Templates/temp02.dwt.php" codeOutsideHTMLIsLocked="false" -->
<style type="text/css">
<!--
#subcontent {
	position:absolute;
	left:243px;
	top:0px;
	width:706px;
	height:59px;
	z-index:1;
	background-color: #70a972;
}
#subcontent01 {
	position:absolute;
	left:22px;
	top:11px;
	width:287px;
	height:39px;
	font:Tahoma;
	font-size:30px;
	font-weight:600px;
	color:#E8E8E8;
	z-index:1;
}
#subcontent02 {
	position:absolute;
	left:312px;
	top:29px;
	font:Tahoma;
	font-size:18px;
	font-weight:500px;
	color:#E8E8E8;
	width:199px;
	height:25px;
	z-index:2;
}
#search01 {
	position:absolute;
	left:1px;
	top:73px;
	width:202px;
	height:69px;
	z-index:1;
}

#searchname {
	position:absolute;
	left:0px;
	top:0px;
	width:202px;
	height:30px;
	z-index:1;
	background-color: #70a972;
	font-family:Tahoma;
	font-size:14px; color:#FFFFFF;
	padding-left:20px;
	padding-top:7px;
}
#text {
	position:absolute;
	left:31px;
	top:37px;
	width:137px;
	height:28px;
	z-index:1;
}
#Layer2 {
	position:absolute;
	left:279px;
	top:353px;
	width:705px;
	height:79px;
	z-index:1;
}
#searchname01 {
	position:absolute;
	left:0px;
	top:0px;
	width:202px;
	height:72px;
	z-index:2;
}
#searchname02 {
	position:absolute;
	left:0px;
	top:0px;
	width:202px;
	height:30px;
	z-index:3;
	background-color: #70a972;
	font-family:Tahoma;
	font-size:14px; color:#FFFFFF;
	padding-left:20px;
	padding-top:7px;
}
#searchname03 {
	position:absolute;
	left:29px;
	top:38px;
	width:139px;
	height:25px;
	z-index:2;
}
#textname {
	position:absolute;
	left:71px;
	top:563px;
	width:164px;
	height:26px;
	z-index:2;
}
#searchtotal {
	position:absolute;
	left:10px;
	top:223px;
	width:204px;
	height:180px;
	z-index:1;
}
.text{
	font-family:Tahoma;
	font-size:14px; color:#0033FF;
	width:135px;
	height:22px;
}
#button {
	position:absolute;
	left:56px;
	top:150px;
	width:78px;
	height:26px;
	z-index:1;
}
-->
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="css/product.css" />
<div id="dhtmltooltip"></div>

<script type="text/javascript">

/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=-100 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

</script>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body>
<?php 
function GetQuantity($id){
		$cart = $_SESSION["CART"];
		$quantity=0;
		foreach(array_keys($cart) as $value){
			if($value == $id){
				$quantity = $cart[$id];
				break;
			}
		}
		return $quantity;	
	} 
?>
<div id="wrap">
	<?php
		if($_SESSION["userlogin"] == false){
	?>
	<div id="title">
		<div id="title01">
			<span><a href="register.php">Register </a>|<a href="cart.php"> My Cart </a>|<a href="login.php"> Login </a></span>
		</div>
	</div>
	<?php } else {?>
	<div id="title">
		<div id="title02">Wellcome <?php echo $_SESSION["username"];?> to MyShop</div>
		<div id="title01">
			<span><a href="user_detail.php?uid=<?php echo $_SESSION["uid"];?>">My Acount </a>|<a href="cart.php?uid=<?php echo $_SESSION["uid"];?>"> My Cart </a>|<a href="logout.php"> Logout </a></span>
		</div>
	</div>
	<?php }?>
	<div id="header">
		<div id="searchform">
	    	<form action="search.php" name="f1" method="post">
					<input type="text" name="s" value="" onKeyPress="this.style.backgroundColor='pink'" onBlur="this.style.backgroundColor='white'" onFocus="this.style.backgroundColor='pink'"/>
			</form>
		</div>
	</div>
	<div id="menu">
		<ul>
			<li><a href="index.php">TRANG CHỦ</a></li>
			<li><a href="introduce.php">GIỚI THIỆU</a></li>
			<li><a href="product_view.php">SẢN PHẨM</a></li>
			<li><a href="promotion.php">KHUYẾN MẠI</a></li>			
			<li><a href="tuvan.php">TƯ VẤN THIẾT BỊ</a></li>
			<li><a href="feedback.php">PHẢN HỒI</a></li>
		</ul>
   </div>
   <div id="submenu">
   		<div id="submennu01"><a href="#">Uy tín/Chất lượng</a></div>
  </div>
   <div id="center">
   		<div id="left">
			<div id="danhmuc"><a href="product_view.php?catid=0">DANH MỤC SẢN PHẨM</a></div>
			<div id="left01">
			  <?php 
					$sql=mysql_query("select * from catagory");
					while($row=mysql_fetch_array($sql))
					{
					   
						echo "<a href='product_view.php?catid={$row["catID"]}'>{$row["catName"]}</a><br>";
						echo "<font color=#727272 >-------------------------------</font><br>";
					}
			?>
			</div>
			<form action="search.php" name="search" method="get" id="search">
			<div id="searchtotal">
			
				<div id="searchname01">
					<div id="searchname02">Tìm sản phẩm theo tên</div>
					<div id="searchname03">
				    <input name="txtkeyword" type="text" class="text" value="">
				  </div>
		  	    </div>
				<div id="search01">
					<div id="searchname">Tìm sản phẩm theo giá</div>
					<div id="text">
					  <select name="slprice" class="text" id="slprice">
                                     <option selected>sản phẩm có giá:</option>
                                     <option value="1">Từ 1 triệu -&gt; 2 Triệu</option>
                                     <option value="2">Từ 2 triệu -&gt; 4 Triệu</option>
                                     <option value="3">Từ 4 triệu -&gt; 6 Triệu</option>
                                     <option value="4">Từ 6 triệu -&gt; 8 Triệu</option>
                                     <option value="5">Từ 8 triệu -&gt; 10 Triệu</option>
                                     <option value="6">Từ 10 triệu trở lên</option>
                  	  </select>
			      </div>				
	    	  </div>			 
			  <div id="button">
		      <input type="submit" name="cmdsearch" value="Tìm Kiếm" style="color:#FF6633;"></div>			   
			</div>
			</form>
			<div id="giohang">
				<div id="giohang01"><a href="cart.php">GIỎ HÀNG CỦA BẠN</a></div>
		  </div>
			<div id="cart">
			  <?php include("cartdetail.php");?></div>
		</div>
		<div id="subcontent">
			<div id="subcontent01">NỘI THẤT CAO CẤP</div>
			<div id="subcontent02">UY TÍN - CHẤT LƯỢNG</div>
		</div>
		<div id="content"><!-- InstanceBeginEditable name="vungsuaduoc" -->
		<?php  
		$a=$_REQUEST["catid"];
		if($a == "") $a = 0;
		if($a == 0){
			$result = mysql_query("select * from product order by pID");
		}else {
			$result = mysql_query("select * from product where catID = {$a} order by pID");
		}
  		$row_per_page=9;		
		$pages=ceil(mysql_num_rows($result)/$row_per_page);
		if($pages!=0){
		?>
			<table border="0" cellspacing=0 cellpadding=3 width=98% align="center" bordercolor="#e8e8e8">
			<?php 
			$page=$_REQUEST["page"];
			if ($page<=0) $page=1;
			if ($page>$pages) $page=$pages;
			
			if($a == 0){
				$result1 = mysql_query("select * from product limit ".(($page-1)*$row_per_page).",{$row_per_page} ");
			}else {
				$result1 = mysql_query("select * from product where catid=$a limit ".(($page-1)*$row_per_page).",{$row_per_page} ");
			}

			$j=0;
			while ($r1=mysql_fetch_array($result1)){
				if ($j==0){echo"<tr>";}{?>
			<div id="dhtmltooltip">
		<td>
			<table border=0.5 bordercolor="#e8e8e8" height=100% align="center">
			<tr>
				<td class="style2" align="center" valign=top width=180 height=23% >
					<a href="chitiet.php?pid=<?php echo $r1["pID"]?>" onMouseover="ddrivetip('<img src=images/<?php echo $r1["pImage"];?> width=200 height=200 border=0/><p style=padding-top:5px><font style=color:red>Gia:<?php echo number_format($r1["pPrice"],1,".",",")?></font><br><font style=color:#3366ff>Mô tả: <?php echo $r1["pDetail"];?></font></p>','#CCCCCC', 200)" onMouseout="hideddrivetip()" onClick="window.location='product_detail.php?pid=<?php echo $r1["pID"]?>'"><font style="color:#70a972; font-family:Tahoma; font-size:15px"><?php echo($r1["pName"])?></font></a>
				</td>
			</tr>
			<tr>
				<td align="center"><br>
					<img src="images/<?php echo($r1["pImage"])?>" onMouseover="ddrivetip('<img src=images/<?php echo $r1["pImage"];?> width=250 height=215 border=0/>','#EDEFF8', 250)" onMouseout="hideddrivetip()" onClick="window.location='product_detail.php?pid=<?php echo $r1["pID"]?>'">
				</td>
			</tr>
			<tr>
				<td height=10% class=style2 align="right">
					<br><a href="cart.php?action=add&pid=<?php echo $r1["pID"];?>"><img src="images/cart.JPG" border="0"></a>
				</td>
			</tr>
			</table>
	    </td>
		  </div>
			<?php $j++;}
				if ($j == 3) {echo "</tr>"; $j=0;}
			}
			 ?>
			 </table>
			 <br><center>
			 <?php  
				for($i = 1; $i <=$pages; $i++)
					if ($i==$page) echo "Trang&nbsp;".$i."&nbsp;";
					else echo "&nbsp;<a href=?catid=$a&page={$i}><font color='blue'>Trang&nbsp;{$i}</font></a>&nbsp;";
			 ?>
			 <br>
			 </center>
	     <?php ;
		 	}else {
				echo"<br><center><h4>Chưa có sản phẩm của hãng này !</h4></center>";
			}?>
			<!-- InstanceEndEditable --></div>
   </div>
   <div id="footer01">
  		<center><a href="#">Design By H3TL&nbsp;Group3<br> Mọi thông tin chi tiết xin liên hệ: h3tl.itpro@gmail.com</a></center>
  </div>
   
</div>





<div id="Layer3"></div>
</body>
<!-- InstanceEnd --></html>
